package com.riche.codefactory.job.once;

import com.riche.codefactory.service.IPostSVC;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;

import javax.annotation.Resource;

/**
 * 全量同步帖子到 es
 *
 *

 */
// todo 取消注释开启任务
//@Component
@Slf4j
public class FullSyncPostToEs implements CommandLineRunner {

    @Resource
    private IPostSVC IPostSVC;

//    @Resource
//    private PostEsDao postEsDao;

    @Override
    public void run(String... args) {
/*        List<Post> postList = IPostSVC.list();
        if (CollUtil.isEmpty(postList)) {
            return;
        }
        List<C2sPostEsDTO> c2sPostEsDTOList = postList.stream().map(C2sPostEsDTO::objToDto).collect(Collectors.toList());
        final int pageSize = 500;
        int total = c2sPostEsDTOList.size();
        log.info("FullSyncPostToEs start, total {}", total);
        for (int i = 0; i < total; i += pageSize) {
            int end = Math.min(i + pageSize, total);
            log.info("sync from {} to {}", i, end);
            postEsDao.saveAll(c2sPostEsDTOList.subList(i, end));
        }
        log.info("FullSyncPostToEs end, total {}", total);*/
    }
}
